package com.cssy.yd.basic.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.yd.basic.dao.BasicBomInfoDAO;
import com.cssy.yd.basic.entity.BasicBomInfoDO;
import com.cssy.yd.basic.entity.BasicBomRawMaterialDO;
import com.cssy.yd.basic.entity.BasicMaterialsDO;
import com.plat.helper.SearchConditions;

/**
 * ��ݷ��ʶ���ʵ����
 * @since 2013-08-15
 */
public class BasicBomInfoDAOImpl extends SqlMapClientDaoSupport implements BasicBomInfoDAO {

    /**
     * �������
     * @param basicBomInfoDO
     * @return ������ݵ�����
     */
    public String insertBasicBomInfoDO(BasicBomInfoDO basicBomInfoDO) {
        Object bill_sequence_id = getSqlMapClientTemplate().insert("BasicBomInfo.insert", basicBomInfoDO);
        return (String) bill_sequence_id;
    }

    /**
     * ͳ�Ƽ�¼��
     * @param basicBomInfoDO
     * @return ����ļ�¼��
     */
    public Integer countBasicBomInfoDOByExample(BasicBomInfoDO basicBomInfoDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicBomInfo.countByDOExample", basicBomInfoDO);
        return count;
    }

    /**
     * ���¼�¼
     * @param basicBomInfoDO
     * @return ��Ӱ�������
     */
    public Integer updateBasicBomInfoDO(BasicBomInfoDO basicBomInfoDO) {
        int result = getSqlMapClientTemplate().update("BasicBomInfo.update", basicBomInfoDO);
        return result;
    }

    /**
     * ��ȡ�����б�
     * @param basicBomInfoDO
     * @return �����б�
     */
    @SuppressWarnings("unchecked")
    public List<BasicBomInfoDO> findListByExample(BasicBomInfoDO basicBomInfoDO) {
        List<BasicBomInfoDO> list = getSqlMapClientTemplate().queryForList("BasicBomInfo.findListByDO", basicBomInfoDO);
        return list;
    }

    /**
     * ��������ȡbasicBomInfoDO
     * @param billSequenceId
     * @return basicBomInfoDO
     */
    public BasicBomInfoDO findBasicBomInfoDOByPrimaryKey(String billSequenceId) {
        BasicBomInfoDO basicBomInfoDO = (BasicBomInfoDO) getSqlMapClientTemplate().queryForObject("BasicBomInfo.findByPrimaryKey", billSequenceId);
        return basicBomInfoDO;
    }

    /**
     * ɾ���¼
     * @param billSequenceId
     * @return ��Ӱ�������
     */
    public Integer deleteBasicBomInfoDOByPrimaryKey(String billSequenceId) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicBomInfo.deleteByPrimaryKey", billSequenceId);
        return rows;
    }

	@Override
	public List<BasicBomInfoDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicBomInfoDO> list = getSqlMapClientTemplate().queryForList("BasicBomInfo_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicBomInfo_ex.count", scs);
		return count;
	}

	@Override
	public List<BasicMaterialsDO> findAllCp(Map<String, Object> map) throws DataAccessException {
		List<BasicMaterialsDO> list = getSqlMapClientTemplate().queryForList("BasicBomInfo_ex.findAllCp",map);
		return list;
	}

	@Override
	public List<BasicBomRawMaterialDO> findRawMaterials(String code)
			throws DataAccessException {
		List<BasicBomRawMaterialDO> list = getSqlMapClientTemplate().queryForList("BasicBomInfo_ex.findRawMaterials",code);
		return list;
	}

	@Override
	public List<BasicBomRawMaterialDO> findSubstituteAll(Map<String, Object> map)
			throws DataAccessException {
		List<BasicBomRawMaterialDO> list = getSqlMapClientTemplate().queryForList("BasicBomInfo_ex.findSubstituteAll",map);
		return list;
	}

	
	@Override
	 public Integer deleteAll() {
	        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicBomInfo_ex.deleteAll");
	        return rows;
	    }
}